package com.roamer.javase.demo.export.vo;

import cn.hutool.core.bean.BeanUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 冷水机组
 *
 * @author roamer
 * @version v1.0
 * @date 2020/5/5 16:51
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class WaterCoolerModel extends ExportModel {
    private static final long serialVersionUID = -5624602772284207224L;

    @Override
    public Map<String, String> getExportHeaderAlias() {
        Map<String, String> map = new LinkedHashMap<>(10);
        map.put("project", "项目名称");
        map.put("brand", "冷机品牌");
        map.put("nameplateLoadFactor", "铭牌功率");
        map.put("date", "日期");
        map.put("time", "时间");
        map.put("deviceName", "设备名称");
        map.put("status", "开启状态");
        map.put("runningTimeOfDay", "当日运行时长");
        map.put("sumRunningTime", "累计运行时长");
        map.put("loadFactor", "运行负载率");
        return map;
    }


    @Override
    public List<int[]> getMergedRegion() {
        List<int[]> list = new ArrayList<>();
        // max防止小于开始行
        list.add(new int[]{2, Math.max(dataItems.size() + 2 - 1, 2), 0, 0, 1});
        list.add(new int[]{2, Math.max(dataItems.size() + 2 - 1, 2), 1, 1, 1});
        list.add(new int[]{2, Math.max(dataItems.size() + 2 - 1, 2), 2, 2, 1});
        list.add(new int[]{2, Math.max(dataItems.size() + 2 - 1, 2), 3, 3, 0});
        return list;
    }

    @Override
    public String getExportTitle() {
        return "多维度数据分析--冷水机组";
    }


    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class WaterCoolerItem extends AbstractDataItem {

        private static final long serialVersionUID = -5934355927198724252L;


        /**
         * 冷机品牌
         */
        private String brand;
        /**
         * 铭牌功率
         */
        private Integer nameplateLoadFactor;
        /**
         * 开启状态
         */
        private String status;
        /**
         * 当日运行时长
         */
        private Integer runningTimeOfDay;
        /**
         * 累计运行时长
         */
        private Integer sumRunningTime;
        /**
         * 运行负载率
         */
        private BigDecimal loadFactor;

        @Override
        protected Map<String, Object> getDataMap() {
            return BeanUtil.beanToMap(this);
        }
    }
}
